﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Text;
using System.Data;

namespace Bussiness_Objects
{
    /// <summary>
    /// Thong tin table PHIEUMUONSACH
    /// ---PHIEUMUONSACH(SoPM,MaDocGia,NgayMuon,NgayPhaiTra,SoSachMuon)
    /// </summary>
    public class PhieuMuonSach : BusinessObjects
    {
        public PhieuMuonSach()
        {

        }

        public PhieuMuonSach(int _soPM, int _maDG, string _ngMuon, string _ngTra, int _soSachM)
        {
            SoPM = _soPM;
            MaDocGia = _maDG;
            NgayMuon = _ngMuon;
            NgayPhaiTra = _ngTra;
            SoSachMuon = _soSachM;
        }

        public void SetParameterSelect()
        {
            parms = new object[1];
            SqlParameter _parm = new SqlParameter(parMaDocGia, MaDocGia);
            parms[0] = _parm;
        }


        public override void SetParameterInsert()
        {
            parms = new object[4];
            SqlParameter _parm = new SqlParameter(parMaDocGia, MaDocGia);
            parms[0] = _parm;

            _parm = new SqlParameter(parNgayMuon, NgayMuon);
            parms[1] = _parm;

            _parm = new SqlParameter(parSoSachMuon, SoSachMuon);
            parms[2] = _parm;

            _parm = new SqlParameter();
            _parm.ParameterName = parSoPM;
            _parm.SqlDbType = SqlDbType.Int;
            _parm.Direction = ParameterDirection.Output;
            parms[3] = _parm;
        }

        public override void SetParameterUpdate()
        {
            parms = new object[4];
            SqlParameter _parm = new SqlParameter(parMaDocGia, MaDocGia);
            parms[0] = _parm;

            _parm = new SqlParameter(parNgayMuon, NgayMuon);
            parms[1] = _parm;

            _parm = new SqlParameter(parSoSachMuon, SoSachMuon);
            parms[2] = _parm;

            _parm = new SqlParameter(parSoPM, SoPM);
            parms[3] = _parm;
        }

        public void SetParameterSelectID()
        {
            parms = new object[1];
            SqlParameter _parm = new SqlParameter(parSoPM, SoPM);
            parms[0] = _parm;
        }

        public void SetParameterDelete()
        {
            SetParameterSelectID();
        }

        public void SetParameterGetByMaDG()
        {
            parms = new object[1];
            SqlParameter _parm = new SqlParameter(parMaDocGia, MaDocGia);
            parms[0] = _parm;
        }

        public void SetParamterGetCTMuon(string ngayTra)
        {
            parms = new object[2];
            SqlParameter _parm = new SqlParameter("@NgayTra", ngayTra);
            parms[0] = _parm;

            _parm = new SqlParameter(parMaDocGia, MaDocGia);
            parms[1] = _parm;
        }

        public int SoPM { get; set; }
        private const string parSoPM = "@SoPM";

        public int MaDocGia { get; set; }
        private const string parMaDocGia = "@MaDocGia";

        public string NgayMuon { get; set; }
        private const string parNgayMuon = "@NgayMuon";

        public string NgayPhaiTra { get; set; }
        private const string parNgayPhaiTra = "@NgayPhaiTra";

        public int SoSachMuon { get; set; }
        private const string parSoSachMuon = "@SoSachMuon";
    }
}
